package com.zrar.ak.gkpt.service.impl.common;

import com.zrar.ak.gkpt.dao.IFormBuildUnitTDao;
import com.zrar.ak.gkpt.model.vo.FormBuildUnitTVO;
import com.zrar.ak.gkpt.service.common.IBuildUnitService;
import com.zrar.ak.gkpt.util.CommonTools;
import com.zrar.ak.gkpt.util.JsonResult;
import com.zrar.ak.gkpt.util.JsonResultEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class BuildUnitService implements IBuildUnitService {

    @Autowired
    private IFormBuildUnitTDao formBuildUnitTDao;


    @Override
    public JsonResult getBuildUnitInfoList(JsonResult jsonResult, String buildUnitName) {
        if(StringUtils.isEmpty(buildUnitName)){
            buildUnitName = null;
        }
        Map map = new HashMap();
        map.put("buildUnitName",buildUnitName);
        List<FormBuildUnitTVO> list = formBuildUnitTDao.getBuildUnitInfoList(map);
        jsonResult.setData(list);
        if(list!=null && list.size()>0){
            CommonTools.jsonResultSetParameter(jsonResult,JsonResultEnum.CODE_SUCCESS);
        }else{
            CommonTools.jsonResultSetParameter(jsonResult,JsonResultEnum.CODE_NONEXISTENT_DATA);
        }
        return jsonResult;
    }
}
